import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;

public class FileInputStream_ {
    public static void main(String[] args) {
        // test1();
        test2();
    }

    public static void test1() {
        try (FileInputStream fileInputStream = new FileInputStream("../.vscode/settings.json")) {
            while (fileInputStream.available() > 0) {
                System.out.print((char) fileInputStream.read()); // 转成char显示
            }
        } catch (IOException e) {
            System.out.println(e.getMessage());
        }
    }

    public static void test2() {
        byte[] buf = new byte[8];
        int readLen = 0;
        try (FileInputStream fileInputStream = new FileInputStream("../.vscode/settings.json")) {
            // 将字节流读取到字节数组中
            while ((readLen = fileInputStream.read(buf)) !=-1) {
                System.out.print(new String(buf, 0, readLen)); // 转成char显示
            }
        } catch (IOException e) {
            System.out.println(e.getMessage());
        }
    }
}
